﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace BlackStar
{
    public class FormContentReader : ContentTypeReader<Form>
    {
        protected override Form Read(ContentReader input, Form existingInstance)
        {
            Form result = new Form();
            result.ReadContent(input);
            return result;
        }
    }

    public class Form : MoveableComponent
    {
        public Form()
        {
        }

        protected override Point GetMinimumSize()
        {
            // this allows us to prevent the minium size from being smaller 
            // than value specified by this component, or the value specified by 
            // the theme for this component.
            return new Point(Math.Max(gui.theme.Form.MinimumSize.X, myMinimumSize.X),
                Math.Max(gui.theme.Form.MinimumSize.Y, myMinimumSize.Y));
        }
                
        protected internal override void ReadContent(ContentReader input)
        {
            base.ReadContent(input);
        }

        public override void Resize()
        {
            if (layoutSuspended) return;
            base.Resize();
            UpdateSkinRects(gui.theme.Form);
        }

        public override void Draw()
        {
            if (!myVisible) return;

            // the bottom right corner will use a differnt texture if it is sizable 
            // as a visual clue to the user.
            if (this.mySizeable)
            {
                gui.theme.Form.Draw("Sizeable", skinRects, this.Color);
            }
            else
            {
                gui.theme.Form.Draw("Default", skinRects, this.Color);
            }

            myGui.theme.Fonts.Draw(myFont, myText, myInterior, this.FontColor); 

            // we call this last because child components should be drawn on top of this.
            DrawComponents();
        }

        
    }


}
